package com.ruoyi.activityAddress.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.activityAddress.domain.ActivityAddress;
import com.ruoyi.activityAddress.service.IActivityAddressService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动地址Controller
 * 
 * @author ruoyi
 * @date 2025-10-13
 */
@RestController
@RequestMapping("/activityAddress/activityAddress")
public class ActivityAddressController extends BaseController
{
    @Autowired
    private IActivityAddressService activityAddressService;

    /**
     * 查询活动地址列表
     */
    @PreAuthorize("@ss.hasPermi('activityAddress:activityAddress:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActivityAddress activityAddress)
    {
        startPage();
        List<ActivityAddress> list = activityAddressService.selectActivityAddressList(activityAddress);
        return getDataTable(list);
    }

    /**
     * 导出活动地址列表
     */
    @PreAuthorize("@ss.hasPermi('activityAddress:activityAddress:export')")
    @Log(title = "活动地址", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActivityAddress activityAddress)
    {
        List<ActivityAddress> list = activityAddressService.selectActivityAddressList(activityAddress);
        ExcelUtil<ActivityAddress> util = new ExcelUtil<ActivityAddress>(ActivityAddress.class);
        util.exportExcel(response, list, "活动地址数据");
    }

    /**
     * 获取活动地址详细信息
     */
    @PreAuthorize("@ss.hasPermi('activityAddress:activityAddress:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(activityAddressService.selectActivityAddressById(id));
    }

    /**
     * 新增活动地址
     */
    @PreAuthorize("@ss.hasPermi('activityAddress:activityAddress:add')")
    @Log(title = "活动地址", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActivityAddress activityAddress)
    {
        return toAjax(activityAddressService.insertActivityAddress(activityAddress));
    }

    /**
     * 修改活动地址
     */
    @PreAuthorize("@ss.hasPermi('activityAddress:activityAddress:edit')")
    @Log(title = "活动地址", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ActivityAddress activityAddress)
    {
        return toAjax(activityAddressService.updateActivityAddress(activityAddress));
    }

    /**
     * 删除活动地址
     */
    @PreAuthorize("@ss.hasPermi('activityAddress:activityAddress:remove')")
    @Log(title = "活动地址", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(activityAddressService.deleteActivityAddressByIds(ids));
    }
}
